﻿using FastORM.Entity;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
using System;
using System.Collections.Generic;
using System.Text;

namespace FastCloud.Base.Desgin
{
    public class CloudModelBinderProvider : IModelBinderProvider
    {
        public IModelBinder GetBinder(ModelBinderProviderContext context)
        {
            if (context == null)
                throw new ArgumentNullException(nameof(context));

            if (context.Metadata.ModelType.BaseType == typeof(BaseEntity))
            {
                return new CloudModelBinder(context.Metadata.ModelType);
            }
            return null;
        }
    }
}
